<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AlterAddTemplateToTemplate extends Migrator
{

    public function up()
    {
        $table = 'template';
        $name = '聚合模板';
        $list = \think\facade\Db::table($table)->where('template_name', $name)->findOrEmpty();

        $data['created_at'] = date("Y-m-d H:i:s");
        if (empty($list)) {
            $data['template_name'] = $name;
            $data['pre_url'] = "/topup/discount/index";
            $data['template_img'] = "https://hfcs.dmjvip.com/template/union.jpg";
            \think\facade\Db::name($table)->insert($data);
        }
    }

    public function down()
    {
        \app\model\Template::query()->where('name', '聚合模板')->delete();
    }
}
